package dr.item.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import dr.controller.*;
import dr.item.dao.ItemDAO;
import dr.item.domain.Item;

public class UpdateFormAction extends ActionSupportLogin {//글수정 폼

	@Override
	public String execute(HttpServletRequest request, 
			HttpServletResponse response) throws Throwable {

		String id=getUserLoginId(request);// session
		
		//admin check
		if(!id.equals("admin")) return ADMINNULL_PATH;
		//admin check
		
		int item_num=0;
		if(request.getParameter("item_num")!=null){
			item_num = Integer.parseInt(request.getParameter("item_num"));
		}
        String pageNum = request.getParameter("pageNum");

        ItemDAO dbPro = ItemDAO.getInstance();
        Item article =  dbPro.updateGetArticle(item_num);

		//해당 뷰에서 사용할 속성
        request.setAttribute("pageNum", new Integer(pageNum));
		request.setAttribute("item_num",new Integer(item_num));
        request.setAttribute("article", article);

		return "/item/updateForm.jsp"; //해당뷰
	}

}



